﻿Imports DevExpress.XtraScheduler.UI
Imports DevExpress.XtraScheduler

Public Class MyAppointmentFormController
    Inherits AppointmentFormController

    Public Property CustomName() As String
        Get
            Return CStr(EditedAppointmentCopy.CustomFields("CustomName"))
        End Get
        Set(ByVal value As String)
            EditedAppointmentCopy.CustomFields("CustomName") = value
        End Set
    End Property
    Public Property CustomStatus() As String
        Get
            Return CStr(EditedAppointmentCopy.CustomFields("CustomStatus"))
        End Get
        Set(ByVal value As String)
            EditedAppointmentCopy.CustomFields("CustomStatus") = value
        End Set
    End Property

    Private Property SourceCustomName() As String
        Get
            Return CStr(SourceAppointment.CustomFields("CustomName"))
        End Get
        Set(ByVal value As String)
            SourceAppointment.CustomFields("CustomName") = value
        End Set
    End Property
    Private Property SourceCustomStatus() As String
        Get
            Return CStr(SourceAppointment.CustomFields("CustomStatus"))
        End Get
        Set(ByVal value As String)
            SourceAppointment.CustomFields("CustomStatus") = value
        End Set
    End Property

    Public Sub New(ByVal control As SchedulerControl, ByVal apt As Appointment)
        MyBase.New(control, apt)
    End Sub

    Public Overrides Function IsAppointmentChanged() As Boolean
        If MyBase.IsAppointmentChanged() Then
            Return True
        End If
        Return SourceCustomName <> CustomName OrElse SourceCustomStatus <> CustomStatus
    End Function

    Protected Overrides Sub ApplyCustomFieldsValues()
        SourceCustomName = CustomName
        SourceCustomStatus = CustomStatus
    End Sub
End Class

